<?php
 require_once('menu.php');
 if ($categoryId) {
    $url = "/{$categoryId}";
 } else {
    $url = "";
 }
 ?>
<script type="text/javascript">
$().ready(function() {
    $("#businessForm").validate({
        errorLabelContainer: $("#businessForm div.error")
    });
});
</script>

<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="menudottedline" width="40%">
        <?php
         if (isset($alert)) {
         ?>
            <div class="pathway">Alert:&nbsp;<?=$alert?></div>
        <?php
         }
         ?>
        </td>
        <td class="menudottedline" align="right">
            <table cellpadding="0" cellspacing="0" border="0" id="toolbar">
                <tr height="60" valign="middle" align="center">
                    <td>
                        <a class="toolbar" href="javascript: document.getElementById('flag').value='category'; submitthis();">
                        <?php echo $html->image('admin/mediamanager_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Categories
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" href="#">
                        <?php echo $html->image('admin/help_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Help
                        </a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<br>
<br>
<div align="center" class="centermain">
    <div class="main">
        <table class="adminheading">
            <tr>
                <th class="info" rowspan="2" nowrap>Add Category</th>
            </tr>
        </table>


        <table class="adminform">
            <tr>
                <td width="60%" valign="top">
                    <form id="businessForm" name="businessForm" method="post" action="<?=$html->url('/admin/add_category'.$url)?>" enctype="multipart/form-data">
                    <div class="error"></div>
                    <table class="adminlist" cellpadding=20>
                    	<tr>
                    		<th>Category Details</th>
                    	</tr>
                    	<tr>
                    		<td align="left"></td>
                    	</tr>
                    </table>

                    <table width="100%">
                        <tr>
                            <td width="60%">
                                <table class="adminlist" cellpadding=20>
                                    <tr>
                                        <td align="left"><font color="red"><b>*</b></font>&nbsp;Category name</td>
                                        <td align="left" style="border: 1px dotted #ccc; background-color: #efefef;">
                                            <input type="text" name="data[category][offer_category]" id="offer_name" style="width: 400px" value="" title="<br/>" class="{required:true}">
                                        </td>
            						</tr>
                                    <tr>
                                        <td align="left"><font color="red"><b>*</b></font>&nbsp;Type</td>
                                        <td align="left" style="border: 1px dotted #ccc; background-color: #efefef;">
                                            <?php echo $form->select('ctype', $ctype, null, array('style' => 'width: 250px;', 'class' => '{required:true}')); ?>
                                        </td>
            						</tr>
                                    <tr>
                                        <td align="left" valign="top">&nbsp;Parent Category</td>
                                        <td align="left" style="border: 1px dotted #ccc; background-color: #efefef; padding: 5px;">
                                            <?php echo $form->select('pcategory', $pcat, null, array('style' => 'width: 250px;', 'class' => '')); ?>
                                            <br/><label><i>**if sub category, please provide its parent category<br/>in the list.</i></label>
                                        </td>
            						</tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td align="left"><input type="submit" value="Save" style="width: 150px;" class="button"></td>
                                    </tr>
                                </table>
                            </td>
                            <td width="40%" valign="top">&nbsp;</td>
                        </tr>
                    </table>

                    <input type="hidden" id="flag" name="data[window][flag]">
                    </form>
                </td>
            </tr>
        </table>

    </div>
</div>

<script type="text/javascript">
<!--
function submitthis()
{
    var flag = document.getElementById('flag').value;
    switch (flag) {
        case "category":
            document.getElementById('flag').value = "category";
            document.businessForm.submit();
            break;
    }
}
-->
</script>